<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>添加大众端用户</title>
	<link rel="stylesheet" href="../layui/css/layui.css"/>
	<style type="text/css">
		.addpubUser-con{
			padding:10px 15px 15px 15px;
			margin-bottom: 40px;
		}
		.addpubUser-con .top-inp{
			margin-left: 20px;
		}
		.addpubUser-con .from-con{
			margin: auto;
			background-color: #E2E2E2;
			padding: 10px;
			overflow: hidden;
		}
		.addpubUser-con .from-con .layui-form-item{
			margin: 30px 0 ;
		}
		.addpubUser-con .not_border_left {
			border-left: none !important;
		}
		.addpubUser-con .layui-form-item .layui-input-block .required {
			color: #ffb800; 
			font-size: 32px; 
			float: left; 
			margin-left: 5px; 
			margin-top: 5px;
			position: absolute;
			right: -15px;
		}
		.addpubUser-con .layui-form-select dl dd.layui-this{
			background-color: #1E9FFF !important;
		}
		 .addpubUser-con .layui-btn{
			background-color: #1E9FFF !important;
		}
		.addpubUser-con .layui-form-select dl{
			max-height:230px !important;
		}
		.addpubUser-con .layui-row .layui-col-xs4{
			text-align: center;
		}
		.addpubUser-con .layui-row .layui-col-xs4 .layui-upload-img{
			width: 200px;
			height: 150px;
			border: 1px solid #e6e6e6;
			background-color: #FFFFFF;
		}
	</style>
</head>
<body>
	<div class="addpubUser-con">
		<div class="from-con">
			<div style="width: 80%;">
				<form class="layui-form" action="">
				  	<div class="layui-form-item" style="margin-top: 10px;">
					    <label class="layui-form-label">用户名</label>
					    <div class="layui-input-block">
					      <input id="userName" type="text" style="float: left;position: relative;" name="userName" lay-verify="required" placeholder="请输入用户名" class="layui-input" autocomplete="off">
					      <i class="required">*</i>
					    </div>
				  	</div>
				  	<div class="layui-form-item" style="margin-top: 10px;">
					    <label class="layui-form-label">真实姓名</label>
					    <div class="layui-input-block">
					      <input id="realname" type="text" name="realname" placeholder="请输入真实姓名" class="layui-input" autocomplete="off">
					    </div>
				  	</div>
				  	<div class="layui-form-item">
					    <label class="layui-form-label">性别</label>
					    <div class="layui-input-block">
					      <input type="radio" name="sex" value="男" title="男" checked>
					      <input type="radio" name="sex" value="女" title="女">
					    </div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">电话</label>
					    <div class="layui-input-block">
					    	<input id="phone" name="phone" type="tel" style="float: left;position: relative;" class="layui-input" placeholder="请输入联系电话" lay-verify="required|phone" autocomplete="off">
					    	<i class="required">*</i>
					    </div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">出生日期</label>
					    <div class="layui-input-block">
					    	<input type="text" name="birthday" id="birthday" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
					    </div>
					</div>
				  	<div class="layui-form-item">
					    <div class="layui-input-block">
					      <button type="button" id="addPubUser" lay-submit="" lay-filter="addPubUser" class="layui-btn" style="float: right;">保  存 </button>
					    </div>
				  	</div>
				</form>
			</div>
		</div>
	</div>
	<script src="../js/jquery-3.3.1.js"></script>
	<script src="../layui/layui.all.js"></script>
	<script type="text/javascript">
		layui.use(['upload','form','laydate'], function(){
			var form = layui.form;
			var laydate = layui.laydate;
			var $ = layui.jquery
  			,upload = layui.upload;
  			
  			//日期
			laydate.render({
			    elem: '#birthday'
			});
			
			//通过表单验证之后才会执行
			form.on('submit(addPubUser)', function(data){
				var username=$("#userName").val();
				var realname=$("#realname").val();
				var sex=$("input[name='sex']:checked").val();
				var birthday=$("#birthday").val();
				var phone=$("#phone").val();
				if(/[\u4E00-\u9FA5]/g.test(username)){
					layer.msg("用户名不能为汉字",{icon:2});
					return false;
				}
				$.ajax({
					url: '../syspublicusermanagement/addpublicuser',  
			        type: 'get', 
			        dataType: 'json',  
			        data:{username:username,realname:realname,sex:sex,
			        	birthday:birthday,phone:phone},
			        success: function (userdata) {
			          if (userdata.code == 10001) {
						  layer.alert('用户信息添加成功！', {icon: 6});
			        	  $("input").val('');
			        	  
			          }else { 
			        	  layer.alert('用户信息添加失败！', {icon: 5});
			        	  return false;
			          }  
			        },
			        error:function(){ 
			        	layer.alert('用户信息添加失败！', {icon: 5});
			        }
				});
			    
			});
		});
	</script>
</body>
</html>